<template>
  <div class="page-header-index-wide">
    <a-card :bordered="false" :bodyStyle="{ padding: '16px 0', height: '100%' }" :style="{ height: '100%' }">
      <div class="account-settings-info-main" :class="{ 'mobile': isMobile }">
        <div class="account-settings-info-left">
          <a-menu
            :mode="isMobile ? 'horizontal' : 'inline'"
            :style="{ border: '0', width: isMobile ? '560px' : 'auto'}"
            :selectedKeys="selectedKeys"
            type="inner"
            @select="handleSelect"
          >
            <a-menu-item v-for="item in menu" :key="item.key">
              <!-- <router-link :to="{ path: item.path }"> -->
              {{ item.title }}
              <!-- </router-link> -->
            </a-menu-item>
          </a-menu>
        </div>
        <div class="account-settings-info-right">
          <div class="account-settings-info-title">
            <span>{{ menu.find(item => item.key === selectedKeys[0]).title }}</span>
          </div>
          <BasicSetting v-if="selectedKeys.includes('basic')" />
          <Custom v-else-if="selectedKeys.includes('custom')" />
          <Security v-else-if="selectedKeys.includes('security')" />
        </div>
      </div>
    </a-card>
  </div>
</template>

<script>
import { baseMixin } from '@/store/app-mixin'

import BasicSetting from "./BasicSetting"
import Binding from "./Binding"
import Custom from "./Custom"
import Security from "./Security"
import Notification from "./Notification"

export default {
  components: {
    BasicSetting,
    Binding,
    Custom,
    Security,
    Notification
  },
  mixins: [baseMixin],
  data () {
    return {
      // horizontal  inline
      mode: 'inline',
      selectedKeys: ['basic'],

      // cropper
      preview: {},
      option: {
        img: '/resource/uploads/1648014883282.png',
        info: true,
        size: 1,
        outputType: 'jpeg',
        canScale: false,
        autoCrop: true,
        // 只有自动截图开启 宽度高度才生效
        autoCropWidth: 180,
        autoCropHeight: 180,
        fixedBox: true,
        // 开启宽度和高度比例
        fixed: true,
        fixedNumber: [1, 1]
      },

      pageTitle: '',
      menu: [
        {
          key: 'basic',
          title: "基本设置"
        },
        {
          key: 'security',
          title: "安全设置"
        },
        {
          key: 'custom',
          title: "个性化"
        }
      ]
    }
  },
  mounted () {
  },
  methods: {
    updateMenu () {
      const routes = this.$route.matched.concat()
      this.selectedKeys = [ routes.pop().path ]
    },
    handleSelect(node) {
      console.log(node)
      this.selectedKeys = [node.key]
    }
  },
}
</script>

<style lang="less" scoped>
  .account-settings-info-main {
    width: 100%;
    display: flex;
    height: 100%;
    overflow: auto;

    &.mobile {
      display: block;

      .account-settings-info-left {
        border-right: unset;
        border-bottom: 1px solid #e8e8e8;
        width: 100%;
        height: 50px;
        overflow-x: auto;
        overflow-y: scroll;
      }
      .account-settings-info-right {
        padding: 20px 40px;
      }
    }

    .account-settings-info-left {
      border-right: 1px solid #e8e8e8;
      width: 224px;
    }

    .account-settings-info-right {
      flex: 1 1;
      padding: 8px 40px;

      .account-settings-info-title {
        color: rgba(0,0,0,.85);
        font-size: 20px;
        font-weight: 500;
        line-height: 28px;
        margin-bottom: 12px;
      }
      .account-settings-info-view {
        padding-top: 12px;
      }
    }
  }

</style>
